home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Languages
/
PowerMacOberon 1.2
/
Source
/
Tools
/
Trace.Mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1995-08-22
|
2KB
|
70 lines
Syntax10.Scn.Fnt
FoldElems
Syntax10.Scn.Fnt
(*-------------------------------------------------------------
Trace provides means for switching debugging output on or off. It maintains an
array of boolean switches that can be set or reset by commands.
Trace.Set int
sets the specified switch to TRUE.
Trace.Reset int
resets the specified switch to FALSE.
Trace.Show
lists all switches that are TRUE.
Trace.Clear
resets all switches to FALSE.
Example
A program may contain debugging output of the form
IF Trace.switch[3] THEN
Out.String("x = "); Out.Int(x, 0); Out.Ln
The user can switch the debugging output on by calling the command
Trace.Set 3
and switch it off by calling the command
Trace.Reset 3
The debugging output can remain in the program during its whole life (with
negigible time overhead) and can be reactivated whenever new errors occurs.
-------------------------------------------------------------*)
Syntax10i.Scn.Fnt
StampElems
Alloc
8 May 95
Syntax10b.Scn.Fnt
Documentation
MODULE Trace; (*HM 94-08-24 /
IMPORT In, Out;
switch-: ARRAY 32 OF BOOLEAN;
PROCEDURE Set*;
VAR i: INTEGER;
BEGIN
In.Open; In.Int(i);
WHILE In.Done DO switch[i] := TRUE; In.Int(i) END
END Set;
PROCEDURE Clear*;
VAR i: INTEGER;
BEGIN
In.Open; In.Int(i);
WHILE In.Done DO switch[i] := FALSE; In.Int(i) END
END Clear;
PROCEDURE Reset*;
VAR i: INTEGER;
BEGIN
FOR i := 0 TO 31 DO switch[i] := FALSE END
END Reset;
PROCEDURE Show*;
VAR i: INTEGER;
BEGIN
Out.String("trace switches:");
FOR i := 0 TO 31 DO
IF switch[i] THEN Out.Int(i, 3) END
END;
Out.Ln
END Show;
BEGIN
Reset
END Trace.
Trace.Set 1 2 4 ~
Trace.Clear 2 ~
Trace.Show
Trace.Reset
Usage
IF Trace.switch[3] THEN print trace output END